from mysql import Mysql
from empinfo import EmpInfo
import json

dbInstance = Mysql()

args = ("张天灵",)
result = dbInstance.get_all("select * from emp_info where name = %s", args)
print(result)

result = dbInstance.get_all("select * from emp_info where name like %s", ("%" + "张" + "%"))
print("打印数组")
print(EmpInfo.convert_list(result))
for item in EmpInfo.convert_list(result):
    print(item)

# dbInstance.begin()
# empId = dbInstance.insert_one("insert into emp_info(id, name) values(%s, %s)", (1002, "张玲"))
# dbInstance.end()
# 自增可以这样
# print(empId)

dbInstance.begin()
effectRows = dbInstance.update("update emp_info set name = %s where id = %s", ("渣1辉", 1002))
dbInstance.end()
print(effectRows)



